package com.taxshare.purchaser.controller;

import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.purchaser.entity.*;
import com.taxshare.purchaser.service.InvoiceCollectionApplyService;
import com.taxshare.purchaser.service.InvoiceCollectionDetailService;
import com.taxshare.purchaser.service.InvoiceCollectionsService;
import com.taxshare.purchaser.view.dto.InvoiceCollectionsDTO;
import com.taxshare.response.beans.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/invoiceCollectionApply")
@Api(tags = "发票归集")
public class InvoiceCollectionApplyController {


    @Autowired
    InvoiceCollectionApplyService invoiceCollectionApplyService;
    @Autowired
    InvoiceCollectionsService invoiceCollectionsService;
    @Autowired
    InvoiceCollectionDetailService invoiceCollectionDetailService;

    /**
     * 批量发票下载申请
     * @param param
     * @return
     */
    @PostMapping(value="/invoiceApply")
    @ResponseBody
    public Map invoiceApply(@RequestBody Map<String, Object> param){
        Map map = new HashMap();
        try {
            map = invoiceCollectionApplyService.invoiceApply(param);
        } catch (Exception e) {
            e.printStackTrace();
            map.put("code", "9999");
        }
        return map;
    }

    @PostMapping("/invoiceCollectionsQuery")
    @ApiOperation(value = "发票归集信息查询", notes = "发票归集主信息")
    public Response<InvoiceCollectionsEntity> invoiceCollectionsQuery(@RequestBody PageRequest<InvoiceCollectionsEntity> query) {
        return invoiceCollectionsService.invoiceCollectionsQuery(query);
    }

    @PostMapping("/invoiceCollectionDetailQuery")
    @ApiOperation(value = "发票归集明细查询", notes = "发票归集明细")
    public Response<InvoiceCollectionsDetailEntity> invoiceCollectionDetailQuery(@RequestBody PageRequest<InvoiceCollectionsDetailEntity> query){
        return invoiceCollectionDetailService.invoiceCollectionDetailQuery(query);
    }




}
